package ssn.common.vo;

import java.io.Serializable;

import egovframework.rte.fdl.string.EgovStringUtil;
import egovframework.rte.ptl.mvc.tags.ui.pagination.PaginationInfo;

public class SearchVO extends PaginationInfo implements Serializable{
	
	private static final long serialVersionUID = -3623253915855255358L;
	
	private int firstIndex = 0;
	private int pageIndex = 1;
	private int pageUnit = 10;
	private int pageSize = 10;
	
	private int rowNum = 0;
	
	/**
	 * 검색 관련 
	 */
	private String searchType;
	private String searchKeyword;
	private String searchCodeKey;
	private String searchServiceArea;
	private String searchSdate;
	private String searchEdate;
	private String searchCodeName;
	private String searchStatus;
	private String searchYear;
	private String searchMonth;
	
	public int getRowNum() {
		return getTotalRecordCount()-(getPageIndex()*getPageUnit()-10);
	}

	public SearchVO() {
		setRecordCountPerPage(pageUnit);
		setCurrentPageNo(pageIndex);
		setPageSize(pageSize);
	}
	
	public void setSearchParam(SearchVO vo) {
		/* search param set*/
		setSearchType(vo.getSearchType());					// 검색 종류 
		setSearchKeyword(vo.getSearchKeyword());			// 검색 키워드
		setSearchCodeKey(vo.getSearchCodeKey());			// 검색 코드키
		setSearchServiceArea(vo.getSearchServiceArea());	// 검색 휴게소
		setSearchSdate(vo.getSearchSdate());				// 검색 날짜 시작
		setSearchEdate(vo.getSearchEdate());				// 검색 날짜 종료
		setSearchStatus(vo.getSearchStatus());				// 상태 검색
		
		/* 페이징 set */
		setPageUnit(vo.getPageUnit());
		setPageIndex(vo.getPageIndex());
		setPageSize(vo.getPageSize());
	}
	
	

	public String getSearchStatus() {
		return searchStatus;
	}

	public void setSearchStatus(String searchStatus) {
		this.searchStatus = searchStatus;
	}

	public String getSearchYear() {
		return searchYear;
	}

	public void setSearchYear(String searchYear) {
		this.searchYear = searchYear;
	}

	public String getSearchMonth() {
		return searchMonth;
	}

	public void setSearchMonth(String searchMonth) {
		this.searchMonth = searchMonth;
	}

	public String getSearchCodeName() {
		return searchCodeName;
	}

	public void setSearchCodeName(String searchCodeName) {
		this.searchCodeName = searchCodeName;
	}

	public String getSearchSdate() {
		if(EgovStringUtil.isEmpty(this.searchSdate) && EgovStringUtil.isNotEmpty(this.searchYear) && EgovStringUtil.isNotEmpty(this.searchMonth)){
			searchSdate = this.searchYear+"-"+this.searchMonth+"-01";
		}
		return searchSdate;
	}

	public void setSearchSdate(String searchSdate) {
		this.searchSdate = searchSdate;
	}

	public String getSearchEdate() {
		if(EgovStringUtil.isEmpty(this.searchEdate) && EgovStringUtil.isNotEmpty(this.searchYear) && EgovStringUtil.isNotEmpty(this.searchMonth)){
			searchEdate = this.searchYear+"-"+this.searchMonth+"-31";
		}
		return searchEdate;
	}

	public void setSearchEdate(String searchEdate) {
		this.searchEdate = searchEdate;
	}

	public String getSearchServiceArea() {
		return searchServiceArea;
	}

	public void setSearchServiceArea(String searchServiceArea) {
		this.searchServiceArea = searchServiceArea;
	}

	public String getSearchCodeKey() {
		return searchCodeKey;
	}

	public void setSearchCodeKey(String searchCodeKey) {
		this.searchCodeKey = searchCodeKey;
	}

	public String getSearchType() {
		return searchType;
	}

	public void setSearchType(String searchType) {
		this.searchType = searchType;
	}

	public String getSearchKeyword() {
		return searchKeyword;
	}

	public void setSearchKeyword(String searchKeyword) {
		this.searchKeyword = searchKeyword;
	}

	public int getPageUnit() {
		return pageUnit;
	}
	public void setPageUnit(int pageUnit) {
		this.pageUnit = pageUnit;
		setRecordCountPerPage(pageUnit);
	}
	public int getPageIndex() {
		return pageIndex;
	}
	public void setPageIndex(int pageIndex) {
		this.pageIndex = pageIndex;
		setCurrentPageNo(pageIndex);
	}
	public int getFirstIndex() {
		return getFirstRecordIndex();
	}
	public void setFirstIndex(int firstIndex) {
		this.firstIndex = firstIndex;
	}
}
